public class Test {

	static public void main(String args[]) throws Exception {
		//read parameters: N, \lambda, \mu, Btotal, Tmax, type:[ideal, simpleChain, backupChain]
		//run simulation
		final long megaByte = 8*1024*1024;
		final long megaBitSec = 1024*1024;
		
		double bTotal = Double.parseDouble(args[0])* megaByte;
		long tMax = Long.parseLong(args[1]) * megaBitSec;
		double lambda = Double.parseDouble(args[2]);
		double mu = Double.parseDouble(args[3]);
		int nodesNum = Integer.parseInt(args[4]);
		long time = Long.parseLong(args[5]);
		String type = args[6];
		int succNum  = Integer.parseInt(args[7]);
		
		
		Simulation sim = null;
		if (type.equals("Ideal")){
			sim = new Ideal(bTotal,tMax ,lambda, mu, nodesNum); 
		} else if(type.equals("Chain")) {
			sim = new Chain(bTotal,tMax ,lambda, mu, nodesNum);
		} else if(type.equals("MultiChain")){
			sim = new MultipleChain(bTotal, tMax, lambda, mu, nodesNum, succNum);
		} else {
			System.out.println("Unknown simulation type.");
			return;
		}

		double  tFill = bTotal/tMax;
		double cyclesToFill = tFill/mu;
		
		double timeWarm = (lambda + mu)* cyclesToFill; 
		
		
		double srcSteps = sim.run(timeWarm, time);
		double average = srcSteps/time; 

		System.out.println(average/tMax);
//		System.out.println("The average throughput is :" + average);
//		System.out.println("The T/Tmax throughput ratio is :" + average/tMax);
//		System.out.println("The steps num: " + srcSteps);
//		System.out.println("The Buffer size is:" + bTotal/megaByte + "(MB)");
	}
}
